{{extends file = '../../layout.html'}}
{{block name = content}}
<div class="row">
    <div class="col-xs-12">
        <h3 class="header smaller lighter blue">文章列表</h3>

        <div class="table-header">
            所有文章-的列表
        </div>

        <div class="table-responsive">
            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th class="center">
                        <label>
                            <input type="checkbox" class="ace"/>
                            <span class="lbl"></span>
                        </label>
                    </th>
                    <th>标题</th>
                    <th>作者</th>
                    <th class="hidden-480">发布时间</th>
                    <th class="hidden-480">分类</th>
                    <th>
                        <i class="icon-time bigger-110 hidden-480"></i>
                        摘要
                    </th>
                    <th class="hidden-480">状态</th>

                    <th></th>
                </tr>
                </thead>

                <tbody>

                {{foreach from=$list item=ls}}
                <tr class="post-{{$ls.id}}">
                    <td class="center">
                        <label>
                            <input type="checkbox" class="ace"/>
                            <span class="lbl"></span>
                        </label>
                    </td>

                    <td>
                        <a href="/post/{{$ls.id}}">{{$ls.title}}</a>
                    </td>
                    <td>{{$ls.author}}</td>
                    <td class="hidden-480">{{$ls.publish_time}}</td>
                    <td class="hidden-480">{{$ls.category}}</td>
                    <td>{{$ls.summary}}</td>

                    <td class="hidden-480">
                        <span class="label label-sm label-warning">{{$ls.status}}</span>
                    </td>

                    <td>
                        <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
                            <a class="blue" href="#">
                                <i class="icon-zoom-in bigger-130"></i>
                            </a>

                            <a class="green" href="/admin?p=post&a=m&id={{$ls.id}}">
                                <i class="icon-pencil bigger-130"></i>
                            </a>

                            <a class="red a-delete" href="javascript:;" data-id="{{$ls.id}}">
                                <i class="icon-trash bigger-130"></i>
                            </a>
                        </div>


                        <div class="visible-xs visible-sm hidden-md hidden-lg">
                            <div class="inline position-relative">
                                <button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown">
                                    <i class="icon-caret-down icon-only bigger-120"></i>
                                    </but   ton>

                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close">
                                        <li>
                                            <a href="#" class="tooltip-info" data-rel="tooltip" title="View">
																				<span class="blue">
																					<i class="icon-zoom-in bigger-120"></i>
																				</span>
                                            </a>
                                        </li>

                                        <li>
                                            <a href="#" class="tooltip-success" data-rel="tooltip" title="Edit">
																				<span class="green">
																					<i class="icon-edit bigger-120"></i>
																				</span>
                                            </a>
                                        </li>

                                        <li>
                                            <a href="#" class="tooltip-error" data-rel="tooltip" title="Delete">
																				<span class="red">
																					<i class="icon-trash bigger-120"></i>
																				</span>
                                            </a>
                                        </li>
                                    </ul>
                            </div>
                        </div>
                    </td>
                </tr>

                {{/foreach}}

                <script>
                    $(function () {
                        $("a.a-delete").click(function () {
                            var flag = confirm('确定删除吗?');
                            var id = $(this).attr('data-id');
                            if (flag) {       //发送ajax请求
                                $.ajax({
                                    type: 'post',
                                    url: "/agent/db/delete",
                                    data: {id: id,model: 'post'},
                                    dataType: 'json',
                                    success: function (data) {
                                        if (data.status == true) {
                                            alert("删除成功！");
                                            $(".post-" + id).remove();        //动态删除网站内容
                                        } else {
                                            alert('删除失败！');
                                            return;
                                        }
                                    },
                                    error: function () {
                                        alert("发生错误！");
                                    }
                                });

                            } else
                                return;
                        });
                    })
                </script>


                </tbody>
            </table>
        </div>
    </div>
</div>
{{/block}}